package com.baidu.service.impl;

import com.baidu.entity.User;
import com.baidu.mapper.UserMapper;
import com.baidu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * @return 所有用户
     * @author ：Xie PinXing
     */

    @Override
    public List<User> selectAll() {
        List<User> userList = userMapper.selectAll();

        /**
         * 遍历集合，将密码设置为******
         * 否则，前端拿到密码，可以明文显示
         * 密码是敏感信息，应该隐藏
         */


//        for (User user : userList) {
//            user.setPassword("******");
//        }


        userList.forEach(user -> user.setPassword("******"));

        return userList;
    }
}
